package BanyuanClub.Study.Day0308;

/**
 * daemon是一个辅助线程
 */
public class TextDaemon {
    public static void main(String[] args) {
        Thread work = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(500);
                    System.out.println(i);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread daemon = new Thread(() -> {
            for (int i = 0;; i++) {
                System.out.println("哈哈哈");
            }
        });
        daemon.setDaemon(true);
        work.start();
        daemon.start();
    }
}
